<!DOCTYPE html>
<html>
<head>
<title>管理员列表</title>
<#include "/header.html">
</head>
<style>
	.el-upload__input {
		display: none !important;
	}

	#container {width:400px; height: 300px; }
</style>
<body>
<div id="rrapp" v-cloak>
	<div v-show="showList">
		<div class="grid-btn">
			<div class="form-group col-sm-2">
				<input type="text" class="form-control" v-model="q.username" @keyup.enter="query" placeholder="用户名">
			</div>
			<a class="btn btn-default" @click="query">查询</a>
			<#if shiro.hasPermission("sys:user:save")>
			<a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
			</#if>
			<#if shiro.hasPermission("sys:user:update")>
			<a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
			</#if>
			<#if shiro.hasPermission("sys:user:delete")>
			<a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
			</#if>
		</div>
	    <table id="jqGrid"></table>
	    <div id="jqGridPager"></div>
    </div>

	<div v-show="!showList" class="panel panel-default">
		<div class="panel-heading">{{title}}</div>
		<form class="form-horizontal">
			<div class="form-group">
				<div class="col-sm-2 control-label">用户名</div>
				<div class="col-sm-10">
					<input type="text" class="form-control" v-model="user.username" placeholder="登录账号"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">所属部门</div>
				<div class="col-sm-10">
					<input type="text" class="form-control" style="cursor:pointer;" v-model="user.deptName" @click="deptTree" readonly="readonly" placeholder="所属部门"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">密码</div>
				<div class="col-sm-10">
					<input type="text" class="form-control" v-model="user.password" placeholder="密码"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">邮箱</div>
				<div class="col-sm-10">
					<input type="text" class="form-control" v-model="user.email" placeholder="邮箱"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">手机号</div>
				<div class="col-sm-10">
					<input type="text" class="form-control" v-model="user.mobile" placeholder="手机号"/>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">角色</div>
				<div class="col-sm-10">
					<label v-for="role in roleList" class="checkbox-inline">
						<input type="checkbox" :value="role.roleId" v-model="user.roleIdList">{{role.roleName}}
					</label>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">状态</div>
				<label class="radio-inline">
					<input type="radio" name="status" value="0" v-model="user.status"/> 禁用
				</label>
				<label class="radio-inline">
					<input type="radio" name="status" value="1" v-model="user.status"/> 正常
				</label>
			</div>
			<div id="doctorid">
				<div class="form-group">
					<div class="col-sm-2 control-label">医生名称</div>
					<div class="col-sm-10">
						<input type="text" class="form-control" v-model="doctor.name" placeholder="医生名称"/>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-2 control-label"><span style="color: red">*</span>医生头像</div>
					<div class="col-sm-10">
						<el-upload
								class="upload-demo"
								action="http://139.159.229.170:8081/renren-api/api/file/uploadfile"
								:on-preview="handlePreview"
								:on-remove="handleRemove"
								:file-list="fileList1"
								:on-success="handsuccess"
								list-type="picture">
							<el-button size="small" type="primary">点击上传</el-button>
						</el-upload>

						<input type="text" class="form-control" v-model="user.headimg" style="display: none;"/>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-2 control-label">详细地址</div>
					<div class="col-sm-10">
						<input type="text" id="detailedaddress" class="form-control" v-model="doctor.address" placeholder="详细地址"/>
					</div>
				</div>

				<div class="form-group">
					<div class="col-sm-2 control-label"></div>
					<div class="col-sm-10" style="width: 400px; height: 300px; border: 1px solid rgb(222, 229, 231);">
						<div id="container"></div>
					</div>

				</div>
				<div class="form-group">
					<div class="col-sm-2 control-label">经度</div>
					<div class="col-sm-10">
						<input type="text" id="longitude" class="form-control" v-model="doctor.longitude" placeholder="经度"/>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-2 control-label">纬度</div>
					<div class="col-sm-10">
						<input type="text" id="latitude" class="form-control" v-model="doctor.latitude" placeholder="纬度"/>
					</div>
				</div>
                <div class="form-group" >
                    <div class="col-sm-2 control-label">医院名称</div>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" v-model="doctor.hospital" placeholder="医院名称"/>
                    </div>
                </div>
			</div>

			<div class="form-group">
				<div class="col-sm-2 control-label"></div>
				<input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
				&nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
			</div>
		</form>
	</div>
</div>

<!-- 选择部门 -->
<div id="deptLayer" style="display: none;padding:10px;">
	<ul id="deptTree" class="ztree"></ul>
</div>

<script src="${request.contextPath}/statics/js/modules/sys/user.js?_${.now?long}"></script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=c6f9f336f0086809dafd67186b9b6406&plugin=Amap.Geocoder"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>

<script type="text/javascript">

    var map = new AMap.Map("container", {
        resizeEnable: true,
        zoom: 10,
        center: [114.3162001,30.58108413], //初始地图中心点
    });
    var geocoder;

    var convertor ;
    AMap.plugin(["AMap.Geocoder"],function () {
        geocoder = new AMap.Geocoder({
            city: "027", //城市设为北京，默认：“全国”
            radius: 1000, //范围，默认：500
        });
    });


    var marker = new AMap.Marker();
    function regeoCode(lnglat) {

        map.add(marker);
        marker.setPosition(lnglat);

        $("#longitude").val(lnglat.lng);
        $("#latitude").val(lnglat.lat);


        geocoder.getAddress(lnglat, function(status, result) {
            if (status === 'complete'&&result.regeocode) {
                var address = result.regeocode.formattedAddress;
                $("#detailedaddress").val(address);

            }else{
                log.error('根据经纬度查询地址失败')
            }
        });
    }

    map.on('click',function(e){
        regeoCode(e.lnglat);
    });

</script>
</body>
</html>